package org.cfg;

import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import java.util.Map;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 蛋池（抓娃娃）
 */
public class GashaponCfg extends BaseCfg<GashaponCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "gashapon";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.GashaponCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 5;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","蛋池物品","行最少出现","蛋池最多出现","蛋池备注",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","eggItems","lineMin","allMax","des",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","eggItems","lineMin","allMax","des",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,-126440773,176884158,-1414904829,99346,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","String","String","String","String",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,String.class,String.class,String.class,String.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 蛋池物品
	 */
	private String eggItems;
	
	/**
	 * 行最少出现
	 */
	private String lineMin;
	
	/**
	 * 蛋池最多出现
	 */
	private String allMax;
	
	/**
	 * 蛋池备注
	 */
	private String des;
	
	
	
	public static GashaponCfg builder() {
		GashaponCfg gashaponCfg = new GashaponCfg();
		return gashaponCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 蛋池物品
	 */
	public String getEggItems() {
		return eggItems;
	}
	
	/**
	 * 行最少出现
	 */
	public String getLineMin() {
		return lineMin;
	}
	
	/**
	 * 蛋池最多出现
	 */
	public String getAllMax() {
		return allMax;
	}
	
	/**
	 * 蛋池备注
	 */
	public String getDes() {
		return des;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.eggItems;
        values[2] = this.lineMin;
        values[3] = this.allMax;
        values[4] = this.des;
        return values;
	}
	
	protected GashaponCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.eggItems = (String)vals[1];
		this.lineMin = (String)vals[2];
		this.allMax = (String)vals[3];
		this.des = (String)vals[4];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.eggItems);
        map.put(keys[2], this.lineMin);
        map.put(keys[3], this.allMax);
        map.put(keys[4], this.des);
        return map;
    }
    
    protected GashaponCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.eggItems = (String)map.get(keys[1]);
   		this.lineMin = (String)map.get(keys[2]);
   		this.allMax = (String)map.get(keys[3]);
   		this.des = (String)map.get(keys[4]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.eggItems);
        obj.put(keys[2], this.lineMin);
        obj.put(keys[3], this.allMax);
        obj.put(keys[4], this.des);
        return obj;
    }
    
    protected GashaponCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.eggItems = obj.getString(keys[1]);
	    this.lineMin = obj.getString(keys[2]);
	    this.allMax = obj.getString(keys[3]);
	    this.des = obj.getString(keys[4]);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeString(this.eggItems);
	    byteBuf.writeString(this.lineMin);
	    byteBuf.writeString(this.allMax);
	    byteBuf.writeString(this.des);
    }
	
	protected GashaponCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.eggItems = byteBuf.readString(null);
	    this.lineMin = byteBuf.readString(null);
	    this.allMax = byteBuf.readString(null);
	    this.des = byteBuf.readString(null);
	    return this;
	}
	
	public GashaponCfg deepCopy(){
		GashaponCfg gashaponCfg = null;
		try {
			gashaponCfg = (GashaponCfg) super.clone();
			return gashaponCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return gashaponCfg;
	}
//自定义内容起始位置
//自定义内容结束位置
}
